home *** CD-ROM | disk | FTP | other *** search
/ Giga Games 1 / Giga Games.iso / net / usenet / volume5 / chess_bd < prev    next >
Encoding:
Internet Message Format  |  1988-07-05  |  5.0 KB

  1. Path: uunet!tektronix!tekgen!tekred!games
  2. From: games@tekred.TEK.COM
  3. Newsgroups: comp.sources.games
  4. Subject: v05i001:  chess-bd - TeX chess position drawing program
  5. Message-ID: <2767@tekred.TEK.COM>
  6. Date: 5 Jul 88 23:04:06 GMT
  7. Sender: billr@tekred.TEK.COM
  8. Lines: 104
  9. Approved: billr@saab.CNA.TEK.COM
  10.  
  11. Submitted by: Charles Blair <ceblair%uxe.cso.uiuc.edu@uxc.cso.uiuc.edu>
  12. Comp.sources.games: Volume 5, Issue 1
  13. Archive-name: chess-bd
  14.  
  15.     [I don't have a TeX system, so you're on your own.  -br]
  16.  
  17. #! /bin/sh
  18. # This is a shell archive.  Remove anything before this line, then unpack
  19. # it by saving it into a file and typing "sh file".  To overwrite existing
  20. # files, type "sh file -c".  You can also feed this as standard input via
  21. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  22. # will see the following message at the end:
  23. #        "End of shell archive."
  24. # Contents:  chess_bd.tex
  25. # Wrapped by billr@saab on Tue Jul  5 16:03:16 1988
  26. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  27. if test -f chess_bd.tex -a "${1}" != "-c" ; then 
  28.   echo shar: Will not over-write existing file \"chess_bd.tex\"
  29. else
  30. echo shar: Extracting \"chess_bd.tex\" \(3646 characters\)
  31. sed "s/^X//" >chess_bd.tex <<'END_OF_chess_bd.tex'
  32. X%
  33. X%  This is a set of macros to be used with plain TeX to print out
  34. X% a diagram of a chess position.  The control sequence \bone 
  35. X% takes as input the Forsyth notation for a position, followed by
  36. X% EEZ as a terminator.  Forsyth notation describes the position
  37. X% one row at a time, with capital letters for white pieces, small
  38. X% letters for black pieces, and uses numbers for empty squares.
  39. X% For example, to print the diagram after Black's third move in Ruy:
  40. X% 
  41. X%  \bone r1bqkbnr 1ppp1ppp p1n5 1B2p3 4P3 5N2 PPPP1PPP RNBQK2R EEZ
  42. X%
  43. X%  Similarly, \btwo can be used to print two adjacent diagrams---
  44. X% you give the Forsyth for one position, then EEZ, then the Forsyth
  45. X% for the other followed by a second EEZ.
  46. X%
  47. X%   To run these macros on your system you may have to modify the 
  48. X% \font instruction indicated below.
  49. X%
  50. X%   The bad thing is that this program seems to be a memory hog.  If
  51. X% I try to print more than three or four diagrams in a letter, I
  52. X% start getting "memory capacity exceeded" messages.  I'm using 
  53. X% PCTEX and have gotten around the problem by using the /m=65000
  54. X% option described on pages I-18 and I-19 of the installation guide.
  55. X%
  56. X%   Improvements for the memory problem or the appearance of the 
  57. X% diagrams are welcome.
  58. X%
  59. X%   As a bonus, the macro \VAR can be used to number the moves of 
  60. X% a variation.  Suppose, for example, you want to list moves from
  61. X% the Schliemann defence to the Ruy, starting with move 3.  Type
  62. X% 
  63. X% \VAR 3 B--N5 P--B4 N-B3! N-B3 PxP B-B4 O-O O-O Z  [Z=terminator]
  64. X%
  65. X% and you get 3 B-N5 P-B4 4 N-B3! N-B3 and so forth.  [also works
  66. X% with algebraic notation.  Sequence of moves from Fine's Practical
  67. X% Chess Openings.]  Unfortunately, this also has memory problems---
  68. X% my machine complains if the variation is longer than ten moves.
  69. X%
  70. X%             ---Charles Blair [BITNET:CEBLAIR@UIUCVMD]
  71. X\magnification=1200
  72. X\newcount\empty \newcount\color% empty keeps track of number of empty
  73. X                               %squares, color tells if shading needed
  74. X\def\ver{\vrule height 15pt}     \font\eightrm=amr8
  75. X% IF YOU ARE NOT USING PCTEX, YOU WILL PROBABLY HAVE TO MODIFY
  76. X% THE \font INSTRUCTION ABOVE TO WHATEVER PRODUCES EIGHT-POINT
  77. X% ROMAN ON YOUR SYSTEM
  78. X\def\hv{\hfil\ver} \def\shade{\hbox to 15pt{\hv\hv\hv\hfil}}
  79. X%shade is a dark square with no piece on it, pshad (below) with piece
  80. X\def\hmv{\hfil\vbox to 15pt{\hrule height 2.6pt width 0.4pt\vfil
  81. X\hrule height 3.0pt width 0.4pt}}
  82. X\def\pshad{\hbox to 15pt{\hmv\hmv\hv\hfil}}
  83. X\def\lett#1{\if #1p{\vbox to 15pt{\vfil\hbox{\eightrm p}\vfil}}%
  84. X\else{\vbox to 15pt{\vfil \hbox{#1} \vfil}}\fi}
  85. X\def\lbt{\ifodd\number\color\hbox to 15pt{\hfil\ver}%
  86. X\else{\rlap{\shade}\hbox to 15pt{\hfil\ver}}\fi}
  87. X\def\lettl#1{\hbox to 15pt{\hfil\lett{#1}\hfil\ver}}
  88. X\def\llt#1{\ifodd\number\color {\lettl#1}\else {\rlap%
  89. X{\pshad}\lettl#1}\fi\advance\color by 1}
  90. X\def\lsr#1#2E{\ifcat 8#1\if 0#1\lsr#2DE\else{\empty=#1
  91. X\advance\empty by -1
  92. X\hbox{\lbt\advance\color by1\lsr{\number\empty}#2E}}\fi%
  93. X\else\if #1D{}\else{\hbox{\llt#1\lsr#2E}}\fi\fi}
  94. X\def\board#1#2Z{\if E#1{{}}\else{\bord#1#2Z}\fi}
  95. X\def\bord#1 #2Z{\vbox{{\hbox{\ver\lsr #1DE}}%
  96. X\hrule width 120.4pt\advance\color by 1\board#2Z}}
  97. X\def\bone#1Z{\color=1\medskip\hbox to \hsize{\hfil\vbox%
  98. X{\hrule width 120.4pt\board#1Z}\hfil}\medskip\color=0}
  99. X\def\btwo#1Z#2Z{\color=1\medskip\hbox to \hsize%
  100. X{\hfil\vbox{\hrule width 120.4pt\board#1Z}\count2=1\hfil\vbox%
  101. X{\hrule width 120.4pt\board#2Z}\hfil}\medskip\count2=0}
  102. X\newcount\move \def\wump#1 #2U{{\number\move}~#1~#2\ }
  103. X\def\VR#1 #2 #3Z{\wump#1 #2U\advance\move by 1\VFIN#3Z}
  104. X\def\VFIN#1#2Z{\if W#1 \move=0 \else \VR#1#2Z\fi}
  105. X\def\VAR#1 #2Z{\move=#1 \VR#2 W W Z}
  106. X
  107. END_OF_chess_bd.tex
  108. if test 3646 -ne `wc -c <chess_bd.tex`; then
  109.     echo shar: \"chess_bd.tex\" unpacked with wrong size!
  110. fi
  111. # end of overwriting check
  112. fi
  113. echo shar: End of shell archive.
  114. exit 0
  115.